package cn.imu.config;


import cn.imu.impl.LiuDeHua;
import cn.imu.impl.MoAttack;

public class ServiceExecuteHelper {
    public static void execute(String serviceName) {
        if(serviceName.equals("moAttack2")) {
            try {
                //验证服务是否存在
                String[] servicClass = ServiceConfig.getService(serviceName);
                //如果服务存在就加载服务信息
                if (servicClass != null && !servicClass.equals("")) {
                    System.out.println(serviceName);
                    System.out.println(servicClass[1]);
                    Class classObject = Class.forName(servicClass[1]);
                    System.out.println(classObject.getName());
                    MoAttack moAttack = (MoAttack) classObject.newInstance();
                    moAttack.cityGateAsk();
                } else {
                    System.out.println("服务" + serviceName + "未定义");
                }
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("服务" + serviceName + "不存在");
            }
        }else if(serviceName.equals("liuDeHua")){
            try {
                //验证服务是否存在
                String[] servicClass = ServiceConfig.getService(serviceName);
                //如果服务存在就加载服务信息
                if (servicClass != null && !servicClass.equals("")) {
                    System.out.println(serviceName);
                    System.out.println(servicClass);
                    Class classObject = Class.forName(servicClass[1]);
                    System.out.println(classObject.getName());
                    LiuDeHua liuDeHua = (LiuDeHua) classObject.newInstance();
                    liuDeHua.responseAsk("墨者革离");
                } else {
                    System.out.println("服务" + serviceName + "未定义");
                }
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("服务" + serviceName + "不存在");
            }
        }
    }

}